<template>
  <a-list
    size="large"
    rowKey="id"
    :loading="loading"
    itemLayout="vertical"
    :dataSource="records"
  >
    <template v-slot:renderItem="{ item }">
      <a-list-item :key="item.id">
        <template v-slot:actions>
          <span>
            <EyeOutlined style="margin-right: 8px" />
            {{ item.views }}
          </span>
          <span
            ><CloudDownloadOutlined style="margin-right: 8px" />
            {{ item.downloadTimes }}
          </span>
          <span
            ><MoneyCollectOutlined style="margin-right: 8px" />
            {{ item.downloadCost }}
          </span>
        </template>
        <a-list-item-meta>
          <template v-slot:title>
            <a href="#">{{ item.materialName }}</a>
          </template>
        </a-list-item-meta>
        <article-list-content
          :description="item.materialIntro"
          :owner="item.owner"
          :avatar="item.avatar"
          :href="item.href"
          :updateAt="item.createTime"
        />
      </a-list-item>
    </template>
    <template v-slot:footer>
      <div
        v-if="records.length > 0"
        style="text-align: center; margin-top: 16px;"
      >
        <a-button @click="loadMore" :loading="loadingMore">加载更多</a-button>
      </div>
    </template>
  </a-list>
</template>
<script lang="ts">
import {
  EyeOutlined,
  CloudDownloadOutlined,
  MoneyCollectOutlined,
} from "@ant-design/icons-vue";
import { getMaterialPageOfMy } from "@/api/Dms/Article/index";
import { ArticleListContent } from "@/components/index";
import { defineComponent, onMounted, ref } from "vue";
export default defineComponent({
  name: "Article",
  components: {
    ArticleListContent,
    EyeOutlined,
    CloudDownloadOutlined,
    MoneyCollectOutlined,
  },
  setup() {
    const records = ref<Array<ArticleVO>>([]);
    const loading = ref(false);
    const loadingMore = ref(false);
    const getList = async () => {
      try {
        loading.value = true;
        const { data } = await getMaterialPageOfMy();
        records.value = data.records;
      } catch (error) {
        console.log(error);
      } finally {
        loading.value = false;
      }
    };
    const loadMore = () => {
      return null;
    };
    onMounted(() => {
      getList();
    });
    return {
      loadMore,
      records,
      loading,
      loadingMore,
    };
  },
});
</script>